package com.infodms.dms.actions.conservation;

import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import com.infodms.dms.actions.repairOrder.RoMaintainMain;
import com.infodms.dms.bean.AclUserBean;
import com.infodms.dms.common.Constant;
import com.infodms.dms.common.ErrorCodeConstant;
import com.infodms.dms.common.Utility;
import com.infodms.dms.common.materialManager.MaterialGroupManagerDao;
import com.infodms.dms.dao.conservation.EnergyConservationOemDao;
import com.infodms.dms.dao.sales.ordermanage.delivery.OrderDeliveryDao;
import com.infodms.dms.dao.sales.ordermanage.orderreport.OrderReportDao;
import com.infodms.dms.exception.BizException;
import com.infodms.dms.po.TtVsEnergyConservationChgPO;
import com.infodms.dms.po.TtVsEnergyConservationPO;
import com.infodms.dms.util.CommonUtils;
import com.infodms.dms.util.csv.CsvWriterUtil;
import com.infodms.dms.util.sequenceUitl.SequenceManager;
import com.infoservice.mvc.context.ActionContext;
import com.infoservice.mvc.context.RequestWrapper;
import com.infoservice.mvc.context.ResponseWrapper;
import com.infoservice.po3.bean.PageResult;

public class EnergyConservationOem {
	
	private static final EnergyConservationOemDao dao = new EnergyConservationOemDao();
	private final OrderReportDao reportDao = OrderReportDao.getInstance();
	public static final EnergyConservationOemDao getInstance() {
		return dao;
	}
	private Logger logger = Logger.getLogger(RoMaintainMain.class);
	private final String ENERGY_CON_DETAIL_QUERY = "/jsp/conservation/conOem/benefitPeople_qry.jsp";// 申请查询页面
	private final String ENERGY_CON_CHECK_QUERY = "/jsp/conservation/conOem/benefitPeople_chk_Init.jsp";
	private final String ENERGY_CON_DETAIL_CHECK = "/jsp/conservation/conOem/benefitPeople_chk_Dtl.jsp";
	private final String ENERGY_CON_EXPORT_QUERY = "/jsp/conservation/conOem/benefitPeople_export.jsp";
	private final String ENERGY_CON_OUTCHECK_QUERY = "/jsp/conservation/conOem/benefitPeople_outcheck.jsp";
	private final String ENERGY_CON_VIEW_DETAIL = "/jsp/conservation/conDlr/benefitPeople_Dlr_Dtl.jsp";
	
	/**
	 * 
	 * @Title: roForward
	 * @Description: TODO(车辆节能惠民信息审核查询)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void vehicleEnergyConQuery() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String COMMAND = CommonUtils.checkNull(request.getParamValue("COMMAND"));
			if(!"".equals(COMMAND)){
				String saleStartDate = CommonUtils.checkNull(request.getParamValue("saleStartDate"));
				String saleEndDate = CommonUtils.checkNull(request.getParamValue("saleEndDate"));
				String reportStartDate = CommonUtils.checkNull(request.getParamValue("reportStartDate"));
				String reportEndDate = CommonUtils.checkNull(request.getParamValue("reportEndDate"));
				String dealerCode = CommonUtils.checkNull(request.getParamValue("dealerCode"));
				String model = CommonUtils.checkNull(request.getParamValue("model"));
				String orgId = CommonUtils.checkNull(request.getParamValue("orgId"));
				String areaId = CommonUtils.checkNull(request.getParamValue("areaId"));
				String energyNo = CommonUtils.checkNull(request.getParamValue("energyNo"));
				String vin = CommonUtils.checkNull(request.getParamValue("vin"));
				if (null != vin && !"".equals(vin)) {
					vin = vin.trim();
				}
				String dPro = CommonUtils.checkNull(request.getParamValue("dPro"));
				String dCity = CommonUtils.checkNull(request.getParamValue("dCity"));
				
				Integer curPage = request.getParamValue("curPage") != null ? Integer
						.parseInt(request.getParamValue("curPage"))
						: 1; // 处理当前页
				PageResult<Map<String, Object>> ps = dao.energyConApplyQuery(saleStartDate,
						saleEndDate,reportStartDate,reportEndDate,dealerCode,model,orgId,areaId,energyNo,vin,dPro,dCity,
						curPage, Constant.PAGE_SIZE);
				act.setOutData("ps", ps);
			}else{
				List<Map<String, Object>> areaBusList=MaterialGroupManagerDao.getPoseIdBusiness(logonUser.getPoseId().toString());
//				List<Map<String, Object>> orgIdList = reportDao.getTMOREG();
				List<Map<String, Object>> orgIdList = OrderDeliveryDao.getInstance().getOemOrg(logonUser.getDutyType(), logonUser.getOrgId()) ;
				act.setOutData("orgIdList", orgIdList);
				act.setOutData("areaBusList", areaBusList);
				act.setForword(ENERGY_CON_CHECK_QUERY);
			}
			
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "车辆节能惠民信息审核查询");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
	/**
	 * 
	 * @Title: roForward
	 * @Description: TODO(车辆节能惠民审核)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void vehicleEnergyConCheck() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String COMMAND = CommonUtils.checkNull(request.getParamValue("COMMAND"));
			if(!"".equals(COMMAND)){
				String conservationId = CommonUtils.checkNull(request.getParamValue("conservationId"));
				String arg = CommonUtils.checkNull(request.getParamValue("arg"));
				TtVsEnergyConservationPO ec = new TtVsEnergyConservationPO();
				ec.setConservationId(Long.valueOf(conservationId));
				TtVsEnergyConservationPO ecValue = new TtVsEnergyConservationPO();
				if("1".equals(arg)){
					ecValue.setConservationStatus(Constant.VEHICLE_ENERGY_CON_SALEPASS);
				}else{
					ecValue.setConservationStatus(Constant.VEHICLE_ENERGY_CON_CANCLE);
				}
					
				ecValue.setUpdateBy(logonUser.getUserId());
				ecValue.setUpdateDate(new Date());
				dao.update(ec, ecValue);
				act.setForword(ENERGY_CON_CHECK_QUERY);
			}else{
				String conservationId = CommonUtils.checkNull(request.getParamValue("conservationId"));
				
				Map<String, Object> map = dao.energyConDetailCheck(conservationId);
				List<Map<String, Object>> listEnergyConStatus = dao.energyConStatusInfo(conservationId);
				act.setOutData("map", map);
				act.setOutData("listEnergyConStatus", listEnergyConStatus);
				act.setOutData("conservationId",conservationId );
				act.setForword(ENERGY_CON_DETAIL_CHECK);
			}
			
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "车辆节能惠民审核");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
	/**
	 * 
	 * @Title: roForward
	 * @Description: TODO(车辆节能惠民批量审核)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void vehicleEnergyConBatchCheck() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String COMMAND = CommonUtils.checkNull(request.getParamValue("COMMAND"));
			if(!"".equals(COMMAND)){
				
			}else{
				String[] conservationIds = request.getParamValues("conservationId");
				for(int i = 0; i < conservationIds.length; i++){
					TtVsEnergyConservationPO ec = new TtVsEnergyConservationPO();
					ec.setConservationId(Long.valueOf(conservationIds[i]));
					TtVsEnergyConservationPO ecValue = new TtVsEnergyConservationPO();
					ecValue.setConservationStatus(Constant.VEHICLE_ENERGY_CON_SALEPASS);
					ecValue.setUpdateBy(logonUser.getUserId());
					ecValue.setUpdateDate(new Date());
					dao.update(ec, ecValue);
					TtVsEnergyConservationChgPO ecc = new TtVsEnergyConservationChgPO();
					ecc.setChangeId(Utility.getLong(SequenceManager.getSequence("")));
					ecc.setConservationId(Long.valueOf(conservationIds[i]));
					ecc.setCreateBy(logonUser.getUserId());
					ecc.setCreateDate(new Date());
					ecc.setStatus(Constant.VEHICLE_ENERGY_CON_SALEPASS);
					ecc.setDescription("批量审核通过！");
					dao.insert(ecc);
				}
				act.setOutData("msg", "01");
			}
			
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "车辆节能惠民批量审核");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
	/**
	 * 
	 * @Title: roForward
	 * @Description: TODO(车辆节能惠民信息导出查询)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void vehicleEnergyConExportQuery() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String COMMAND = CommonUtils.checkNull(request.getParamValue("COMMAND"));
			if(!"".equals(COMMAND)){
				
				String reportStartDate = CommonUtils.checkNull(request.getParamValue("reportStartDate"));
				String reportEndDate = CommonUtils.checkNull(request.getParamValue("reportEndDate"));
				String dealerCode = CommonUtils.checkNull(request.getParamValue("dealerCode"));
				String model = CommonUtils.checkNull(request.getParamValue("model"));
				String orgId = CommonUtils.checkNull(request.getParamValue("orgId"));
				String areaId = CommonUtils.checkNull(request.getParamValue("areaId"));
				String energyNo = CommonUtils.checkNull(request.getParamValue("energyNo"));
				String vin = CommonUtils.checkNull(request.getParamValue("vin"));
				if (null != vin && !"".equals(vin)) {
					vin = vin.trim();
				}
				String dPro = CommonUtils.checkNull(request.getParamValue("dPro"));
				String dCity = CommonUtils.checkNull(request.getParamValue("dCity"));
				
				Integer curPage = request.getParamValue("curPage") != null ? Integer
						.parseInt(request.getParamValue("curPage"))
						: 1; // 处理当前页
				PageResult<Map<String, Object>> ps = dao.energyConExportQuery(
						reportStartDate,reportEndDate,dealerCode,model,orgId,areaId,energyNo,vin,dPro,dCity,
						curPage, Constant.PAGE_SIZE);
				act.setOutData("ps", ps);
			}else{
				List<Map<String, Object>> areaBusList=MaterialGroupManagerDao.getPoseIdBusiness(logonUser.getPoseId().toString());
				List<Map<String, Object>> orgIdList = OrderDeliveryDao.getInstance().getOemOrg(logonUser.getDutyType(), logonUser.getOrgId()) ;
				act.setOutData("orgIdList", orgIdList);
				act.setOutData("areaBusList", areaBusList);
				act.setForword(ENERGY_CON_EXPORT_QUERY);
			}
			
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "车辆节能惠民信息导出查询");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
	
	/**
	 * 车辆节能惠民信息下载
	 */
	public void vehicleEnergyConExportDo(){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = null;
		RequestWrapper request = act.getRequest();
		ResponseWrapper response = act.getResponse();
		logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
		act.getSession().get(Constant.LOGON_USER);

		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
		Calendar   calendar = Calendar.getInstance();
		Long timeStr = Long.parseLong(sdf.format(calendar.getTime()).toString());
		
		// 导出的文件名
		String fileName = "节能惠民申请_"+timeStr+".csv";
		// 导出的文字编码
		OutputStream os = null;
		try {
			
			
			fileName = new String(fileName.getBytes("GB2312"), "ISO8859-1");
			response.setContentType("Application/text/csv");
			response.addHeader("Content-Disposition", "attachment;filename="+ fileName);

			List<List<Object>> list = new LinkedList<List<Object>>();
			List<Object> listTemp = new LinkedList<Object>();
			listTemp.add("节能惠民单号");
			listTemp.add("上报日期");
			listTemp.add("经销商代码");
			listTemp.add("经销商名称");
			listTemp.add("车型代码");
			listTemp.add("车型");
			listTemp.add("消费者名称");
			listTemp.add("联系人");
			listTemp.add("联系电话");
			listTemp.add("VIN");
			listTemp.add("销售日期");
			list.add(listTemp);
			
			String reportStartDate = CommonUtils.checkNull(request.getParamValue("reportStartDate"));
			String reportEndDate = CommonUtils.checkNull(request.getParamValue("reportEndDate"));
			String dealerCode = CommonUtils.checkNull(request.getParamValue("dealerCode"));
			String model = CommonUtils.checkNull(request.getParamValue("model"));
			String orgId = CommonUtils.checkNull(request.getParamValue("orgId"));
			String areaId = CommonUtils.checkNull(request.getParamValue("areaId"));
			String energyNo = CommonUtils.checkNull(request.getParamValue("energyNo"));
			String vin = CommonUtils.checkNull(request.getParamValue("vin"));
			if (null != vin && !"".equals(vin)) {
				vin = vin.trim();
			}
			String dPro = CommonUtils.checkNull(request.getParamValue("dPro"));
			String dCity = CommonUtils.checkNull(request.getParamValue("dCity"));
			
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1; // 处理当前页
			PageResult<Map<String, Object>> ps = dao.energyConExportQuery(
					reportStartDate,reportEndDate,dealerCode,model,orgId,areaId,energyNo,vin,dPro,dCity,
					curPage, 100000);
			List<Map<String, Object>> results  = ps.getRecords();
			
			if(results!=null && !results.equals("")){

				for (int i = 0; i < results.size(); i++) {
					Map<String, Object> record = results.get(i);
					listTemp = new LinkedList<Object>();
					listTemp.add(CommonUtils.checkNull(record.get("CONSERVATION_NO")));
					listTemp.add(CommonUtils.checkNull(record.get("CREATE_DATE")));
					listTemp.add(CommonUtils.checkNull(record.get("DEALERCODE")));
					listTemp.add(CommonUtils.checkNull(record.get("DEALERNAME")));
					listTemp.add(CommonUtils.checkNull(record.get("MODELCODE")));
					listTemp.add(CommonUtils.checkNull(record.get("MODELNAME")));
					listTemp.add(CommonUtils.checkNull(record.get("CTM_NAME")));
					listTemp.add(CommonUtils.checkNull(record.get("CTM_LINKMAN")));
					listTemp.add(CommonUtils.checkNull(record.get("CTM_LINKTEL")));
					listTemp.add(CommonUtils.checkNull(record.get("VIN")));
					listTemp.add(CommonUtils.checkNull(record.get("PURCHASED_DATE")));
					list.add(listTemp);
					//设置导出标识
					TtVsEnergyConservationPO ec = new TtVsEnergyConservationPO();
					ec.setConservationId(Long.valueOf(record.get("CONSERVATION_ID").toString()));
					TtVsEnergyConservationPO ecValue = new TtVsEnergyConservationPO();
					ecValue.setIsExport(1);
	
					ecValue.setExportFlag(timeStr);
					ecValue.setExportPose(logonUser.getPoseId());
					ecValue.setExportUser(logonUser.getUserId());
					ecValue.setUpdateBy(logonUser.getUserId());
					ecValue.setUpdateDate(new Date());
					dao.update(ec, ecValue);
				}
			}
			os = response.getOutputStream();
			CsvWriterUtil.writeCsv(list, os);		
			os.flush();
		}catch(Exception e) {//异常方法
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"车辆节能惠民信息下载");
			logger.error(logonUser,e1);
			act.setException(e1);
		}
	}
	/**
	 * 
	 * @Title: roForward
	 * @Description: TODO(车辆节能惠民信息外部审核查询)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void vehicleEnergyConOutCheckQuery() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String COMMAND = CommonUtils.checkNull(request.getParamValue("COMMAND"));
			if(!"".equals(COMMAND)){
				
				String saleStartDate = CommonUtils.checkNull(request.getParamValue("saleStartDate"));
				String saleEndDate = CommonUtils.checkNull(request.getParamValue("saleEndDate"));
				String reportStartDate = CommonUtils.checkNull(request.getParamValue("reportStartDate"));
				String reportEndDate = CommonUtils.checkNull(request.getParamValue("reportEndDate"));
				String dealerCode = CommonUtils.checkNull(request.getParamValue("dealerCode"));
				String model = CommonUtils.checkNull(request.getParamValue("model"));
				String orgId = CommonUtils.checkNull(request.getParamValue("orgId"));
				String areaId = CommonUtils.checkNull(request.getParamValue("areaId"));
				String energyNo = CommonUtils.checkNull(request.getParamValue("energyNo"));
				String vin = CommonUtils.checkNull(request.getParamValue("vin"));
				if (null != vin && !"".equals(vin)) {
					vin = vin.trim();
				}
				String expVer = CommonUtils.checkNull(request.getParamValue("expVer"));
				String dPro = CommonUtils.checkNull(request.getParamValue("dPro"));
				String dCity = CommonUtils.checkNull(request.getParamValue("dCity"));
				
				Integer curPage = request.getParamValue("curPage") != null ? Integer
						.parseInt(request.getParamValue("curPage"))
						: 1; // 处理当前页
				PageResult<Map<String, Object>> ps = dao.energyConOutCheckQuery(
						expVer,saleStartDate,
						saleEndDate,reportStartDate,reportEndDate,dealerCode,model,orgId,areaId,energyNo,vin,dPro,dCity,
						curPage, 400);
				act.setOutData("ps", ps);
			}else{
				List<Map<String,Object>> listExpVer = dao.energyConExportVerNoQuery(logonUser.getUserId().toString());
				List<Map<String, Object>> areaBusList=MaterialGroupManagerDao.getPoseIdBusiness(logonUser.getPoseId().toString());
				List<Map<String, Object>> orgIdList = OrderDeliveryDao.getInstance().getOemOrg(logonUser.getDutyType(), logonUser.getOrgId()) ;
				act.setOutData("orgIdList", orgIdList);
				act.setOutData("areaBusList", areaBusList);
				act.setOutData("listExpVer", listExpVer);
				act.setForword(ENERGY_CON_OUTCHECK_QUERY);
			}
			
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "车辆节能惠民信息外部审核查询");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
	
	/**
	 * 
	 * @Title: roForward
	 * @Description: TODO(车辆节能惠民信息外部审核)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void vehicleEnergyConBatchFinalCheck() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String COMMAND = CommonUtils.checkNull(request.getParamValue("COMMAND"));
			if(!"".equals(COMMAND)){
				
			}else{
				String[] conservationIds = request.getParamValues("conservationId");
				String[] allConservationIds = request.getParamValues("allConservationId");
				Integer statusTemp = Constant.VEHICLE_ENERGY_CON_CANCLE;
				String desc = "外部审批驳回";
				for(int i = 0; i < allConservationIds.length; i++){
					
					for(int j = 0; j < conservationIds.length; j++){
						System.out.println("1>"+allConservationIds[i]+" <2>"+conservationIds[j]);
						if(allConservationIds[i].equals(conservationIds[j])){
							statusTemp = Constant.VEHICLE_ENERGY_CON_PASS;
							desc = "外部审批通过";
							break;
						}else{
							statusTemp = Constant.VEHICLE_ENERGY_CON_CANCLE;
							desc = "外部审批驳回";
						}
					}
					TtVsEnergyConservationPO ec = new TtVsEnergyConservationPO();
					ec.setConservationId(Long.valueOf(allConservationIds[i]));
					TtVsEnergyConservationPO ecValue = new TtVsEnergyConservationPO();
					ecValue.setConservationStatus(statusTemp);
//					ecValue.setStatus(Constant.STATUS_DISABLE);
					ecValue.setUpdateBy(logonUser.getUserId());
					ecValue.setUpdateDate(new Date());
					dao.update(ec, ecValue);
					TtVsEnergyConservationChgPO ecc = new TtVsEnergyConservationChgPO();
					ecc.setChangeId(Utility.getLong(SequenceManager.getSequence("")));
					ecc.setConservationId(Long.valueOf(allConservationIds[i]));
					ecc.setCreateBy(logonUser.getUserId());
					ecc.setCreateDate(new Date());
					ecc.setStatus(Constant.VEHICLE_ENERGY_CON_PASS);
					ecc.setDescription(desc);
					dao.insert(ecc);
				}
				act.setOutData("msg", "01");
			}
			
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "车辆节能惠民信息外部审核");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
	/**
	 * 节能惠民信息明细查看（OEM）
	 */
	public void vehicleEnergyConOemQuery() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String COMMAND = CommonUtils.checkNull(request.getParamValue("COMMAND"));
			if(!"".equals(COMMAND)){
				String postId = logonUser.getPoseId().toString();
				String saleStartDate = CommonUtils.checkNull(request.getParamValue("saleStartDate"));
				String saleEndDate = CommonUtils.checkNull(request.getParamValue("saleEndDate"));
				String reportStartDate = CommonUtils.checkNull(request.getParamValue("reportStartDate"));
				String reportEndDate = CommonUtils.checkNull(request.getParamValue("reportEndDate"));
				String dealerCode = CommonUtils.checkNull(request.getParamValue("dealerCode"));
				String model = CommonUtils.checkNull(request.getParamValue("model"));
				String orgId = CommonUtils.checkNull(request.getParamValue("orgId"));
				String areaId = CommonUtils.checkNull(request.getParamValue("areaId"));
				String energyNo = CommonUtils.checkNull(request.getParamValue("energyNo"));
				String vin = CommonUtils.checkNull(request.getParamValue("vin"));
				if (null != vin && !"".equals(vin)) {
					vin = vin.trim();
				}
				String dPro = CommonUtils.checkNull(request.getParamValue("dPro"));
				String dCity = CommonUtils.checkNull(request.getParamValue("dCity"));
				String status = CommonUtils.checkNull(request.getParamValue("status"));
				
				Integer curPage = request.getParamValue("curPage") != null ? Integer
						.parseInt(request.getParamValue("curPage"))
						: 1; // 处理当前页
				
				PageResult<Map<String,Object>> ps = dao.energyConViewQuery(
						saleStartDate,saleEndDate,orgId,
						dPro,dCity,dealerCode,
						reportStartDate, reportEndDate, model, 
						 areaId, status, energyNo, vin, postId,
						curPage, Constant.PAGE_SIZE);
				act.setOutData("ps", ps);
			}else{
				List<Map<String, Object>> areaBusList=MaterialGroupManagerDao.getPoseIdBusiness(logonUser.getPoseId().toString());
				List<Map<String, Object>> orgIdList = OrderDeliveryDao.getInstance().getOemOrg(logonUser.getDutyType(), logonUser.getOrgId()) ;
				act.setOutData("orgIdList", orgIdList);
				act.setOutData("areaBusList", areaBusList);
				act.setForword(ENERGY_CON_DETAIL_QUERY);
			}
			
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "节能惠民信息明细查看");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
}
